/**
 * Yolema.com Inc.
 * Copyright (c) 2011-2012 All Rights Reserved.
 */
package org.grayrabbit.pay.facade.common;

import org.grayrabbit.pay.facade.enums.ErrorCodeEnum;
import org.grayrabbit.pay.facade.exception.PayClientException;


/**
 * 
 * @author wangy
 * @version $Id: TradeConstants.java, v 0.1 2012-6-5 上午10:45:58 wy Exp $
 */
public class TradeConstants {
    /**
     * 退款状态码
     */
    public enum RefundCode {

        
        REFUND_PAY_ACCEPT("系统已受理受理"),
        REFUND_TERMINAL_ACCEPT("终端已受理受理"),
        REFUND_CANCEL("取消退款"),
        REFUND_FAIL("退款失败"),
        REFUND_SUCCESS("退款成功");

        private String msg;

        public String getMsg() {
            return msg;
        }

        RefundCode(String msg) {
            this.msg = msg;
        }
        
        /**
         * 根据状态获取对应的enum
         * 
         * @param tradeStatus
         * @return
         */
        public static RefundCode getRefundEnum(String tradeStatus){
            for(RefundCode te:RefundCode.values()){
                if(te.name().equalsIgnoreCase(tradeStatus.trim())){
                    return te;
                }
            }
            throw new PayClientException(ErrorCodeEnum.ENUM_UN_KNOWN);
        }

    }

    /**
     * 交易状态
     */
    public enum TradeCode {
        
        PAY_WAIT("待支付"),
        PAY_CANCEL("已取消"),
        PAY_IN_HAND("交易处理中"),
        FAIL_PAY("支付失败"),
        PAY_SUCCESS("支付成功");

        private String msg;

        public String getMsg() {
            return msg;
        }

        TradeCode(String msg) {
            this.msg = msg;
        }
        /**
         * 根据状态获取对应的enum
         * 
         * @param tradeStatus
         * @return
         */
        public static TradeCode getTradeEnum(String tradeStatus){
            for(TradeCode te:TradeCode.values()){
                if(te.name().equalsIgnoreCase(tradeStatus.trim())){
                    return te;
                }
            }
            throw new PayClientException(ErrorCodeEnum.ENUM_UN_KNOWN);
        }
    }
}
